﻿using Hidistro.Membership.Context;
using Hidistro.SaleSystem.Catalog;
using Hidistro.SaleSystem.Comments;
using Hidistro.UI.Common.Controls;
using System;
using System.Web.UI.HtmlControls;

namespace Hidistro.UI.SaleSystem.CodeBehind
{
    public class JuseshangchengDetail : HtmlTemplatedWebControl
    {
        
        private int ProductId;
        protected override void AttachChildControls()
        {
            if (!string.IsNullOrEmpty(Context.Request["ProductId"]))
                ProductId = int.Parse(Context.Request["ProductId"].ToString());

            System.Data.DataTable dt = ProductBrowser.GetProductReview(ProductId);
            if (dt != null && dt.Rows.Count > 0)
            {
                LoadPageSearch(dt);
            }
            else
            {
                PageTitle.AddSiteNameTitle("橘色商城");
            }

            
        }
        private void LoadPageSearch(System.Data.DataTable dt)
        {
            if (dt.Rows[0]["ReviewMeta_Keywords"]!=null)
            {
                MetaTags.AddMetaKeywords(dt.Rows[0]["ReviewMeta_Keywords"].ToString(), HiContext.Current.Context);
            }
            if (dt.Rows[0]["ReviewMeta_Description"]!=null)
            {
                MetaTags.AddMetaDescription(dt.Rows[0]["ReviewMeta_Description"].ToString(), HiContext.Current.Context);
            }
            if (dt.Rows[0]["ReviewMeta_Title"] != null && dt.Rows[0]["ReviewMeta_Title"].ToString()!="")
            {
                PageTitle.AddSiteNameTitle(dt.Rows[0]["ReviewMeta_Title"].ToString());
            }
            else
            {
                PageTitle.AddSiteNameTitle(dt.Rows[0]["ProductName"].ToString());
            }
        }
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "/juseshangcheng/Skin-JuseshangchengDetail.html";
            }
            base.OnInit(e);
        }
    }
}
